package com.ruoyi.web.controller.TiebaShares.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.web.controller.TiebaShares.domain.TiebaShares;
import com.ruoyi.web.controller.TiebaShares.mapper.TiebaSharesMapper;
import com.ruoyi.web.controller.TiebaShares.service.ITiebaSharesService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;


/**
 * 分享的表的情况Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-09
 */
@Service
public class TiebaSharesServiceImpl extends ServiceImpl<TiebaSharesMapper, TiebaShares> implements ITiebaSharesService {

    @Autowired
    private TiebaSharesMapper tiebaSharesMapper;

    /**
     * 查询分享的表的情况列表
     *
     * @param tiebaShares 分享的表的情况
     * @return 分享的表的情况
     */
    @Override
    public List<TiebaShares> selectTiebaSharesList(TiebaShares tiebaShares)
    {
        List<TiebaShares> tiebaSharesList = tiebaSharesMapper.selectList(buildQueryWrapper(tiebaShares));
        return tiebaSharesList;
    }


    private LambdaQueryWrapper<TiebaShares> buildQueryWrapper(TiebaShares query) {
        Map<String, Object> params = query.getParams();
        LambdaQueryWrapper<TiebaShares> lqw = Wrappers.lambdaQuery();
        lqw.eq(query.getPostId() != null, TiebaShares::getPostId, query.getPostId());
        lqw.eq(query.getUserId() != null, TiebaShares::getUserId, query.getUserId());
        lqw.eq(query.getDeptId() != null, TiebaShares::getDeptId, query.getDeptId());
        lqw.eq(query.getShareTime() != null, TiebaShares::getShareTime, query.getShareTime());
        lqw.orderByDesc(TiebaShares::getCreateTime);
        lqw.eq(query.getOtherUserId() != null, TiebaShares::getOtherUserId, query.getOtherUserId());
        return lqw;
    }

}
